<?php
namespace hook\src;
use hook\src\Config;
class Log
{
    private static $log_file_name = 'log.txt';

    private static $log_file_path = '../log/';

    private static $data = [];

    public static function log_path()
    {
        if(!is_dir(Config::Log_File_Path)){
            return mkdir(Config::Log_File_Path, 0777);
        }else{
            return mkdir(self::$log_file_path, 0777); 
        }
    }


    public static function save_log_file(Array $data)
    {
        self::$data = $data;
        $res_log = '-------------------------' . PHP_EOL;
        $res_log .= self::$data['user_name'] . ' 在' . date('Y-m-d H:i:s') . '向' . self::$data['repository']['name'] . '项目的' . self::$data['ref'] . '分支push了' . self::$data['total_commits_count'] . '个commit：';
        $res_log .= $res . PHP_EOL;
        $res_log .= "pull end --------" . PHP_EOL;
        file_put_contents($file, self::$data, FILE_APPEND); 
    }
}